package com.example.audiodemo.service;

import com.example.audiodemo.audio.AudioCloudPlayer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.websocket.Session;
import java.util.List;

@Slf4j
@Service
public class SpeakService {

    @Autowired
    private AudioCloudPlayer audioCloudPlayer;


    public void open(Session session) {
        audioCloudPlayer.init();
    }

    public void speak(Session session, byte[] voice) {
        audioCloudPlayer.pushStream(voice);
    }

    public void close(Session session) {
        audioCloudPlayer.stop();
    }


    public void start(List<String> deviceNoList) {
        audioCloudPlayer.start(deviceNoList);
    }

    public void stop() {
        audioCloudPlayer.stop();
    }

}

